# Contributor: Mitch Tishmack <mitch.tishmack@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=upx
pkgver=4.2.4
pkgrel=0
pkgdesc="The Ultimate Packer for eXecutables"
url="https://upx.github.io/"
# s390x, riscv64: tests fail due to unknown executable format
arch="all !s390x !riscv64"
license="GPL-2.0-or-later"
makedepends="cmake samurai"
subpackages="$pkgname-doc"
source="https://github.com/upx/upx/releases/download/v$pkgver/upx-$pkgver-src.tar.xz"
builddir="$srcdir/$pkgname-$pkgver-src"

# secfixes:
#   4.0.2-r0:
#     - CVE-2023-23456
#     - CVE-2023-23457
#   4.0.0-r0:
#     - CVE-2020-24119
#     - CVE-2020-27796
#     - CVE-2020-27797
#     - CVE-2020-27798
#     - CVE-2020-27799
#     - CVE-2020-27800
#     - CVE-2020-27801
#     - CVE-2020-27802
#     - CVE-2021-30500
#     - CVE-2021-30501
#   3.96-r1:
#     - CVE-2021-20285
#   3.96-r0:
#     - CVE-2018-11243
#     - CVE-2019-14296
#     - CVE-2019-20021
#     - CVE-2019-20053

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DUPX_CONFIG_DISABLE_WERROR=ON \
		-DUPX_CONFIG_DISABLE_SANITIZE=ON \
		-DUPX_CONFIG_DISABLE_GITREV=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
fc833dea010cb65a9a7b6fbf80021c98d8c112b55fa54101f3d39f09d049d75d89024206a28262996c08f253130917811736f7f546fa8743703bc86a2dbd33a5  upx-4.2.4-src.tar.xz
"
